package com.test;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class IncludeAction extends ChildrenAction {
	Set<Object> attrNames = null;
	public IncludeAction(Set<Object> attrNames ){
		this.attrNames = attrNames;
	}
	
	public boolean doIt(JsonWriter w, JsonKey key,List<Item> value) {
		Iterator<Item> it = value.iterator();
		while(it.hasNext()){
			Item item = it.next();
			Object name = item.getKey().getName();
			if(!attrNames.contains(name)){
				it.remove();
			}
		}
		return true;
	}
}
